<template>
  <el-form class="add-event-number" v-if="wbData">
    <input-normal type="number" label="目标总计数（所有人）" placeholder="限制总计数" v-model="wbData.total"  @change="onUpdateWbComponent"></input-normal>
    <switch-normal v-model="wbData.isUid" label="个人行为" @change="onUpdateWbComponent"></switch-normal>
    <input-normal type="number" label="每天限制分配计数" placeholder="每天限制分配计数" v-model="wbData.day_limit"  @change="onUpdateWbComponent"></input-normal>
    <input-normal type="number" label="限制总计数" placeholder="限制总计数" v-model="wbData.total_limit"  @change="onUpdateWbComponent"></input-normal>
    <input-normal type="number" label="调整计数基数" placeholder="如果开启个人，则为个人基数" v-model="wbData.base"  @change="onUpdateWbComponent"></input-normal>
    <switch-normal v-model="wbData.isDynamic" label="动态修改" @change="onUpdateWbComponent"></switch-normal>
    <input-normal type="number" label="每次增加或减少计数值" v-model="wbData.onceGrowValue"  @change="onUpdateWbComponent"></input-normal>
    <input-normal type="number" label="vip每次增加或减少计数值" v-model="wbData.vipOnceGrowValue"  @change="onUpdateWbComponent"></input-normal>
    <input-normal  label="每天缺省增加计数值" v-model="wbData.day_default" @change="onUpdateWbComponent"></input-normal>
    <input-normal label="触发计数关联id" v-model="wbData.syn_com_id" @change="onUpdateWbComponent"></input-normal>
  </el-form>
</template>

<script setup lang="ts">
import { useWebControlsStore } from '@/store/web/controls'

const props = defineProps<{ 
  event: IEvent,
  index: number,
}>()

const event = props.event
const useWebControls = useWebControlsStore()

let wbData_: any
const wbData = computed(() => {
  try {
    wbData_ = useWebControls.currentControls![event.controlId] && useWebControls.currentControls![event.controlId].data
  } catch (error) {
    console.log("controlData.data null")
  }
  return wbData_
})
const onUpdateWbComponent = () => {
  useWebControls.updateWbComponent({ controlId: event.controlId, data: wbData_ })
}
</script>
